package com.naihe.anderson.sms.activity;

import com.naihe.anderson.sms.R;
import com.naihe.anderson.sms.application.NhSmsApp;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;

public class ExplainActivity extends Activity implements OnClickListener{

	ImageView image;
	RelativeLayout image_layout;
	NhSmsApp nhSmsApp;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.explain_layout);
        
        nhSmsApp = (NhSmsApp) getApplication();
        nhSmsApp.setActivity(this);
        String explainActivity = getIntent().getStringExtra("fromActivity");
        
        image = (ImageView) findViewById(R.id.image);
        image.setOnClickListener(this);
        if(explainActivity.equals("CapitalNumberInfoActivity")){
        	image.setBackgroundResource(R.drawable.capital_info_explain);
        }
        image_layout = (RelativeLayout) findViewById(R.id.image_layout);
        image_layout.setOnClickListener(this);
	}

	private void toFinishActivity(){
		nhSmsApp.setActivity(null);
		ExplainActivity.this.finish();
		System.gc();
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			toFinishActivity();
			return true;
		}

		return super.onKeyDown(keyCode, event);
	}
	
	@Override
	public void onClick(View v) {
		toFinishActivity();
	}

}
